#include <iostream>
#define LL long long
using namespace std;
const int kMaxN = 1e5 + 10;

int diff[kMaxN], times[kMaxN];

void Add(int l, int r) {
  if (l > r) {
    swap(l, r);
  }
  diff[l]++;
  diff[r]--;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;

  int last;

  cin >> last;
  for (int i = 1; i < m; i++) {
    int now;

    cin >> now;
    Add(last, now);
    last = now;
  }

  for (int i = 1; i < n; i++) {
    times[i] = times[i - 1] + diff[i];
  }
  LL ans = 0;
  for (int i = 1; i < n; i++) {
    int a, b, c;

    cin >> a >> b >> c;
    ans += min((LL)a * times[i], (LL)b * times[i] + c);
  }
  cout << ans << "\n";
  return 0;
}